package com.fs.zise;

import Tools.BitmapTool;
import android.R.integer;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;

public class Mirror {

	private Bitmap mirrorBitmap ;
	private int mirror_direction = -1;
	private int mirror_Row;
	private int mirror_Col;
//	private int mirror_frameIndex = 0;
	
	private GameSurfaceView gameSurfaceView;
	
	public int getMirror_Row() {
		return mirror_Row;
	}

	public void setMirror_Row(int mirror_Row) {
		this.mirror_Row = mirror_Row;
	}

	
	public int getMirror_Col() {
		return mirror_Col;
	}

	public void setMirror_Col(int mirror_Col) {
		this.mirror_Col = mirror_Col;
	}

	Mirror(GameSurfaceView gameSurfaceView,int mirror_Row,int mirror_Col,int mirror_Dir)
	{
		this.gameSurfaceView = gameSurfaceView;
		this.mirror_Row = mirror_Row;
		this.mirror_Col = mirror_Col;
		this.mirror_direction = mirror_Dir;
		
		System.out.println("LaserEmitter.LaserEmitter()--mirror_Row ="+mirror_Row);
		System.out.println("LaserEmitter.LaserEmitter()--mirror_Col ="+mirror_Col);
		System.out.println("LaserEmitter.LaserEmitter()--mirror_direction ="+mirror_direction);
		InitMirror();
	}
	
	
	
	private void InitMirror()
	{
		if(mirrorBitmap == null)
			mirrorBitmap = Bitmap.createBitmap(BitmapTool.getImageFromAssetFile("mirror.png"), 96, 0, 16, 24);
	}

	public int getMirrorDir()
	{
		return mirror_direction;
	}
	
	public void changeMirrorDir()
	{
		this.mirror_direction = (this.mirror_direction == GameMap.MIRROR_DIRECTION_XIE_1TH)?GameMap.MIRROR_DIRECTION_XIE_2TH:GameMap.MIRROR_DIRECTION_XIE_1TH;
	}
	
	public void drawMirror(Canvas canvas,Paint paint)
	{
//		System.out.println("LaserEmitter.drawMirror()--mirror_direction ="+mirror_direction);
		switch(mirror_direction)
		{
		case GameMap.MIRROR_DIRECTION_XIE_1TH:
			BitmapTool.drawRegoin(canvas, paint, mirrorBitmap, 0,
					mirror_Col*48+16, mirror_Row*48+12, 0, 0, 16, 24);
			break;
		case GameMap.MIRROR_DIRECTION_XIE_2TH:
			BitmapTool.drawRegoin(canvas, paint, mirrorBitmap, 1,
					mirror_Col*48+16, mirror_Row*48+12, 0, 0, 16, 24);
			break;
		}
	}
	
	public boolean getMirror(int row,int  col)
	{
		if(this.mirror_Row == row && this.mirror_Col ==col )
			return true;
		return false;
	}
}
